"""
数据模式定义
"""
from pydantic import BaseModel
from typing import List, Dict, Any, Optional
from datetime import datetime

class UserBase(BaseModel):
    """用户基础模型"""
    user_id: str
    username: Optional[str] = None
    email: Optional[str] = None

class UserCreate(UserBase):
    """创建用户模型"""
    pass

class User(UserBase):
    """用户模型"""
    id: int
    created_at: datetime
    updated_at: datetime

    class Config:
        from_attributes = True

class UserProfileBase(BaseModel):
    """用户画像基础模型"""
    user_id: str
    knowledge_level: Optional[str] = "beginner"
    learning_style: Optional[str] = "visual"
    interests: Optional[List[str]] = []
    progress: Optional[Dict[str, float]] = {}

class UserProfileCreate(UserProfileBase):
    """创建用户画像模型"""
    pass

class UserProfileUpdate(UserProfileBase):
    """更新用户画像模型"""
    pass

class UserProfile(UserProfileBase):
    """用户画像模型"""
    id: int
    created_at: datetime
    updated_at: datetime

    class Config:
        from_attributes = True

class DocumentBase(BaseModel):
    """文档基础模型"""
    title: str
    content: str
    doc_type: str
    source: Optional[str] = None

class DocumentCreate(DocumentBase):
    """创建文档模型"""
    pass

class Document(DocumentBase):
    """文档模型"""
    id: int
    created_at: datetime
    updated_at: datetime

    class Config:
        from_attributes = True

class QueryModel(BaseModel):
    """查询模型"""
    question: str
    user_id: str

class RecommendationModel(BaseModel):
    """推荐模型"""
    user_id: str
    subject: str

class ProgressUpdateModel(BaseModel):
    """进度更新模型"""
    user_id: str
    subject: str
    progress: float

class QuestionAnswerResponse(BaseModel):
    """问答响应模型"""
    question: str
    answer: str
    sources: List[str]
    confidence: float

class LearningPathStage(BaseModel):
    """学习路径阶段模型"""
    stage: int
    topic: str
    description: str
    estimated_time: str
    resources: List[str]

class LearningPathResponse(BaseModel):
    """学习路径响应模型"""
    user_id: str
    subject: str
    learning_path: List[LearningPathStage]

class DocumentProcessModel(BaseModel):
    """文档处理模型"""
    file_path: str
    file_type: str  # "text" or "pdf"
    use_mineru_pages: Optional[List[int]] = None